#pragma once

class t_MessageRecipient;
class t_MessageQueue;

// Basic class for message. Customer message can be inherited from this class if necessary
class t_Message
{
	// t_MessageQueue class has access to the protected variables.
	// This is necessary to change p_MessageQueue member when adding a message to a message queue
	friend class t_MessageQueue; 

protected:
	int type; //!< Message Type
	int msg;  //!< Message Code
	clock_t p_Clock; //!< Time when the message should be delivered
	t_MessageRecipient* p_MessageRecipient; //!< Recipient of the message
	t_MessageQueue* p_MessageQueue; //!< Back reference to the Message Queue containing this message

public:
	t_Message(t_MessageRecipient* p_MessageRecipient, int type, clock_t tm);
	t_Message(t_MessageRecipient* p_MessageRecipient, int type, int msg, clock_t tm);
	t_Message(const t_Message &); //!< Copy constructor
	virtual ~t_Message(void);

	virtual void operator = (const t_Message &); 
	virtual bool operator < (const t_Message &); //!< "less" operator is required to sort messages by delivery time

	int GetType(){return type;};
	int GetMsg() {return msg;};
	clock_t GetTime() {return p_Clock;};
	t_MessageRecipient* GetRecipient(){return p_MessageRecipient;};
	t_MessageQueue* GetMessageQueue(){return p_MessageQueue;};

};
